--剑盾骑士
local jiandunqishi = fk.CreateSkill {
    name = "mcdh_jiandunqishi",
}

local U = require "packages/utility/utility"
local lib = require "packages/mcdh/lib"

jiandunqishi:addEffect(fk.DamageCaused,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and player:usedSkillTimes(self.name) == 0 and target and (target:getMark("mcdh_charge_max")- target:getMark("mcdh_charge")) > 0
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(player,self.name,nil,event == fk.DamageCaused and "#mcdh_jiandunqishi_damage:"..target.id or "#mcdh_jiandunqishi_damaged:"..target.id)
    end,
    on_use = function(self, event, target, player, data)
        lib.RecoverCharge(player,target,1,self.name)
    end
})

jiandunqishi:addEffect(fk.DamageInflicted,{
    can_trigger = function(self, event, target, player, data)
        return player:hasSkill(self) and player:usedSkillTimes(self.name) == 0 and target and (target:getMark("mcdh_charge_max")- target:getMark("mcdh_charge")) > 0
    end,
    on_cost = function(self, event, target, player, data)
        return player.room:askForSkillInvoke(player,self.name,nil,event == fk.DamageCaused and "#mcdh_jiandunqishi_damage:"..target.id or "#mcdh_jiandunqishi_damaged:"..target.id)
    end,
    on_use = function(self, event, target, player, data)
        lib.RecoverCharge(player,target,1,self.name)
    end
})

Fk:loadTranslationTable {
    ["mcdh_jiandunqishi"] = "干戚",
    [":mcdh_jiandunqishi"] = "『剑盾骑士』<br>每回合限一次，当一名角色造成或受到伤害时，你可以令其回复1点技力。",
    ["#mcdh_jiandunqishi_damage"] = "剑盾骑士：%src 即将造成伤害，是否令其回复1点技力？",
    ["#mcdh_jiandunqishi_damaged"] = "剑盾骑士：%src 即将受到伤害，是否令其回复1点技力？",
}

return jiandunqishi